import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;


public class WordsWithA {

	public static void getWordsStartingWithA(String file1, String file2, char letter) throws FileNotFoundException {
		Scanner sc = new Scanner(new File(file1));
		PrintStream printer = new PrintStream(new File(file2));
		String words = "";
		while(sc.hasNext()) {
			System.out.println("hmm");
			words = sc.next(); // chete do razdelitel space, posle spira i prodyljava
			if (words.startsWith(""+letter)) 
				System.out.println("ole");
				printer.println(words);
				
		}		
//		String[] wordsArr = words.split(" ");
//		for (String word:wordsArr) {
//			if (word.startsWith(""+letter)){
//				printer.println(words)
//			}
//		}
		printer.close();
		sc.close();
	}
	
	
	public static void main(String[] args)  {
		try {
			getWordsStartingWithA("file1.txt", "fileA.txt", 'a');
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

}
